USE [OctoNetApps]
GO

/****** Object:  StoredProcedure [classified].[ClassifiedResources_Save]    Script Date: 05/25/2011 07:02:30 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



CREATE PROCEDURE [classified].[ClassifiedResources_Save]
	@ResourceID bigint,
	@Latitude float,
	@Longitude float,
	@AllowAnonymousAds bit,
	@Comments tinyint,
	@AllowRenewal bit,
	@AutoExpireAnonymousDays smallint,
	@AutoExpireNonAnonymousDays smallint,
	@AdApprove bit,
	@CurrencyID tinyint,
	@AdminMail varchar(100)
AS
BEGIN

	SET NOCOUNT ON;
		
    UPDATE classified.ClassifiedResources
    SET AllowAnonymousAds = @AllowAnonymousAds,
		Comments = @Comments,
		AllowRenewal = @AllowRenewal,
		AutoExpireAnonymousDays = @AutoExpireAnonymousDays,
		AutoExpireNonAnonymousDays = @AutoExpireNonAnonymousDays,
		DefaultLocation = geography::Point(@Latitude, @Longitude, 4326),
		AdApprove = @AdApprove,
		CurrencyID = @CurrencyID,
		AdminMail = @AdminMail
	WHERE ResourceID = @ResourceID
	
	IF @@ROWCOUNT = 0
	BEGIN
		INSERT INTO classified.ClassifiedResources
		VALUES (@ResourceID, null, geography::Point(@Latitude, @Longitude, 4326), @AllowAnonymousAds, @Comments,
		@AllowRenewal, @AutoExpireAnonymousDays, @AutoExpireNonAnonymousDays, 0, @AdApprove, @CurrencyID, @AdminMail)
	END
END


GO


